<template>
  <view class="normal-login-container">
    <view class="uni-common-mt">
    	<view class="uni-form-item uni-column">
    		<view class="title">用户名</view>
    		<input v-model="user.username" class="uni-input" focus placeholder="用户名" />
    	</view>
    	<view class="uni-form-item uni-column">
    		<view class="title">密码</view>
    		<input type="password" v-model="user.password" class="uni-input"  placeholder="密码" />
    	</view>
    	<view class="uni-form-item uni-column">
    		<button type="primary" plain="true" @click="doLogin">登录</button>
    	</view>
		{{user}}
	</view>
  </view>
</template>

<script>
  import {login2} from '@/api/login.js'
  export default {
    data() {
      return {
        user:{
			username:'admin',
			password:'123123'
		}
      }
    },
    created() {
      // uni.switchTab({
      // 	url:"/pages/index"
      // })
    },
    methods: {
      doLogin(){
		  login2(this.user).then(res=>{
			  if(res.code==200){
				  uni.setStorageSync("token", res.data)
				  uni.switchTab({
				  	url:'/pages/index'
				  })
				  
			  }else{
			  }
		  })
	  }
    }
  }
</script>

<style lang="scss">
  .normal-login-container{
	  .uni-form-item{
		  padding:20upx;
	  }
	  padding:50px;
	  .title{
		  font-size: 40upx;
	  }
	  .uni-input{
		  border:solid 1px grey;
		  font-size: 40upx;
	  }
  }

</style>
